package cn.hpclub.server.model;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.plugin.activerecord.Model;

import cn.hpclub.server.constant.Constant;

/**
 * 实体类 - 角色
 * 
 */
@TableBind(tableName = "device_version")
public class DeviceVersion extends Model<DeviceVersion>{
    private static final long         serialVersionUID = -7381179371331061521L;
    public static final DeviceVersion dao              = new DeviceVersion();

    public DeviceVersion getAavailableVersion(String version, String type, String sysFlag){
        return findFirst("SELECT * FROM device_version WHERE version>? AND appid=? AND type=? AND ispublic=1 ORDER BY VERSION DESC",
                         version, Constant.APPID, type);

    }

    /**
     * @param type
     * @Title: getHighestVersion
     * @Description:获取最高版本的APK信息
     * @return DeviceVersion
     */
    public DeviceVersion getHighestVersion(String type){
        return findFirst("SELECT * FROM device_version WHERE version = (SELECT max(version) FROM device_version WHERE type=? AND appid=?)",
                         type, Constant.APPID);
    }
}
